package co.edu.unal.scrum.server.guice;

import co.edu.unal.scrum.server.model.ProductBacklog;
import co.edu.unal.scrum.server.model.ProductBacklogItem;
import co.edu.unal.scrum.server.model.SprintBacklog;
import co.edu.unal.scrum.server.model.SprintItem;
import co.edu.unal.scrum.server.model.Team;
import co.edu.unal.scrum.server.model.TeamMember;
import co.edu.unal.scrum.server.model.UserDetail;
import co.edu.unal.scrum.shared.model.Project;

import com.google.code.twig.ObjectDatastore;
import com.google.code.twig.annotation.AnnotationObjectDatastore;
import com.google.code.twig.configuration.DefaultConfiguration;
import com.google.inject.Provider;

public class ObjectDatastoreProvider implements Provider<ObjectDatastore> {

	static {
	DefaultConfiguration.registerTypeName(UserDetail.class, "UserDetail");
	DefaultConfiguration.registerTypeName(Team.class, "Team");
	DefaultConfiguration.registerTypeName(TeamMember.class, "TeamMember");
	DefaultConfiguration.registerTypeName(SprintBacklog.class, "SprintBacklog");
	DefaultConfiguration.registerTypeName(SprintItem.class, "SprintItem");
	DefaultConfiguration.registerTypeName(Project.class, "Project");
	DefaultConfiguration.registerTypeName(ProductBacklog.class, "ProductBacklog");
	DefaultConfiguration.registerTypeName(ProductBacklogItem.class, "ProductBacklogItem");

	}
	private Boolean indexed = false;
	private int activationDepth = 4;

	@Override
	public ObjectDatastore get() {
		// TODO Auto-generated method stub
		ObjectDatastore datastore = new AnnotationObjectDatastore(indexed);

		datastore.setActivationDepth(activationDepth);
		return datastore;
	}

}
